﻿namespace DimensionsHelper.Common.Metadata.Script;

/// <summary>
///     布尔常量值表达式。
/// </summary>
public class BooleanExpression : LiteralExpression
{
    /// <summary>
    ///     布尔常量值表达式。
    /// </summary>
    public BooleanExpression(int start) : base(LiteralKinds.Boolean, start)
    {
    }

    /// <summary>
    ///     布尔表达式的布尔值(true/false)。
    /// </summary>
    public bool Value { get; private set; } = true;

    public override ExpressionBasicType Evaluate()
    {
        return new ExpressionBoolean(Value);
    }

    public override void Finish(int end, string text)
    {
        base.Finish(end, text);
        Value = bool.Parse(text);
    }
}